//package org.example.test;
//
//import org.deeplearning4j.nn.graph.ComputationGraph;
//import org.example.processor.FeatureExtractor;
//import org.example.processor.FeatureStorage;
//import org.example.processor.ImageProcessor;
//import org.example.util.SimilaritySearch;
//import org.example.util.XrFileUtil;
//import org.nd4j.common.io.ClassPathResource;
//import org.nd4j.linalg.api.ndarray.INDArray;
//
//import java.io.File;
//
///**
// * DeepLearning4j & ND4J
// *
// * 来源：Maven Central
// *
// * 用途：深度学习模型加载与计算
// *
// * 许可：Apache 2.0
// *
// * OpenCV Java Bindings
// *
// * 来源：Maven Central (org.openpnp:opencv)
// *
// * 用途：图像处理（如需要）
// *
// * 许可：BSD
// *
// * VGG16预训练模型
// *
// * 来源：Keras Applications（需自行转换为DL4J格式）
// *
// * 用途：图像特征提取
// *
// * 许可：MIT
// *
// */
//public class ProductSearchDemo {
//    public static void main(String[] args) {
//        try {
//            // 1. 加载模型(单项处理)
////            ComputationGraph model = FeatureExtractor.loadModel();
////            ClassPathResource resource = new ClassPathResource("img/11.jpg");
////            File file = resource.getFile();
////            String absolutePath = file.getAbsolutePath();
////            // 2. 处理商品图片并存储特征
////            INDArray productImage = ImageProcessor.preprocessImage(absolutePath);
////            INDArray productFeature = ImageProcessor.extractFeatures(productImage, model);
////            FeatureStorage.storeFeature("product_001", productFeature);
////            // 3. 处理用户查询图片
////            INDArray queryImage = ImageProcessor.preprocessImage( new ClassPathResource("img/11.jpg").getFile().getAbsolutePath());
////            INDArray queryFeature = ImageProcessor.extractFeatures(queryImage, model);
////
////            // 4. 搜索相似商品
////            String similarProductId = SimilaritySearch.findMostSimilar(queryFeature);
////            System.out.println("最相似的商品ID: " + similarProductId);
//
//
//            ComputationGraph model = FeatureExtractor.loadModel();
//            String imageDir = "/img";
//            int batchSize = 100;
//            XrFileUtil xrFileUtil = new XrFileUtil();
//            xrFileUtil.processDirectory(imageDir,batchSize,model);
//            // 3. 处理用户查询图片
//            INDArray queryImage = ImageProcessor.preprocessImage( new ClassPathResource("img/11.jpg").getFile().getAbsolutePath());
//            INDArray queryFeature = ImageProcessor.extractFeatures(queryImage, model);
//
//            // 4. 搜索相似商品
//            String similarProductId = SimilaritySearch.findMostSimilar(queryFeature);
//            System.out.println("最相似的商品ID: " + similarProductId);
//        }catch (Exception e){
//            System.out.println(e);
//        }
//
//    }
//}
